//
// NeL - bindings
// Copyright (C) 2010 Naush
//
//This program is free software: you can redistribute it and/or modify
//it under the terms of the GNU Affero General Public License as
//published by the Free Software Foundation, either version 3 of the
//License, or (at your option) any later version.
//
//This program is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//GNU Affero General Public License for more details.
//
//You should have received a copy of the GNU Affero General Public License
//along with this program.  If not, see <http://www.gnu.org/licenses/>.
package org.ryzom.nel.misc;

public class TBMSSerialInfo {
  private long swigCPtr;
  protected boolean swigCMemOwn;

  public TBMSSerialInfo(long cPtr, boolean cMemoryOwn) {
    swigCMemOwn = cMemoryOwn;
    swigCPtr = cPtr;
  }

  public static long getCPtr(TBMSSerialInfo obj) {
    return (obj == null) ? 0 : obj.swigCPtr;
  }

  protected void finalize() {
    delete();
  }

  public synchronized void delete() {
    if (swigCPtr != 0) {
      if (swigCMemOwn) {
        swigCMemOwn = false;
        nelmiscJNI.delete_TBMSSerialInfo(swigCPtr);
      }
      swigCPtr = 0;
    }
  }

  public TBMSSerialInfo(long bitpos, long bitsize, TBMSSerialInfo.TSerialType type, String symbol) {
    this(nelmiscJNI.new_TBMSSerialInfo(bitpos, bitsize, type.swigValue(), symbol), true);
  }

  public void setBitPos(long value) {
    nelmiscJNI.TBMSSerialInfo_BitPos_set(swigCPtr, this, value);
  }

  public long getBitPos() {
    return nelmiscJNI.TBMSSerialInfo_BitPos_get(swigCPtr, this);
  }

  public void setBitSize(long value) {
    nelmiscJNI.TBMSSerialInfo_BitSize_set(swigCPtr, this, value);
  }

  public long getBitSize() {
    return nelmiscJNI.TBMSSerialInfo_BitSize_get(swigCPtr, this);
  }

  public void setType(TBMSSerialInfo.TSerialType value) {
    nelmiscJNI.TBMSSerialInfo_Type_set(swigCPtr, this, value.swigValue());
  }

  public TBMSSerialInfo.TSerialType getType() {
    return TBMSSerialInfo.TSerialType.swigToEnum(nelmiscJNI.TBMSSerialInfo_Type_get(swigCPtr, this));
  }

  public void setSymbol(String value) {
    nelmiscJNI.TBMSSerialInfo_Symbol_set(swigCPtr, this, value);
  }

  public String getSymbol() {
    return nelmiscJNI.TBMSSerialInfo_Symbol_get(swigCPtr, this);
  }

  public final static class TSerialType {
    public final static TSerialType B = new TSerialType("B");
    public final static TSerialType U = new TSerialType("U");
    public final static TSerialType U64 = new TSerialType("U64");
    public final static TSerialType F = new TSerialType("F");
    public final static TSerialType BF = new TSerialType("BF");
    public final static TSerialType Buffer = new TSerialType("Buffer");
    public final static TSerialType NbSerialTypes = new TSerialType("NbSerialTypes");

    public final int swigValue() {
      return swigValue;
    }

    public String toString() {
      return swigName;
    }

    public static TSerialType swigToEnum(int swigValue) {
      if (swigValue < swigValues.length && swigValue >= 0 && swigValues[swigValue].swigValue == swigValue)
        return swigValues[swigValue];
      for (int i = 0; i < swigValues.length; i++)
        if (swigValues[i].swigValue == swigValue)
          return swigValues[i];
      throw new IllegalArgumentException("No enum " + TSerialType.class + " with value " + swigValue);
    }

    private TSerialType(String swigName) {
      this.swigName = swigName;
      this.swigValue = swigNext++;
    }

    private TSerialType(String swigName, int swigValue) {
      this.swigName = swigName;
      this.swigValue = swigValue;
      swigNext = swigValue+1;
    }

    private TSerialType(String swigName, TSerialType swigEnum) {
      this.swigName = swigName;
      this.swigValue = swigEnum.swigValue;
      swigNext = this.swigValue+1;
    }

    private static TSerialType[] swigValues = { B, U, U64, F, BF, Buffer, NbSerialTypes };
    private static int swigNext = 0;
    private final int swigValue;
    private final String swigName;
  }

}
